﻿<include file="Public/header"/>
<include file="Public/menu"/>
<div class="page-content">
	<div class="page-header">
		<h1>
			节点
			<small>
				<i class="icon-double-angle-right"></i>
				浏览节点
			</small>
		</h1>
	</div>
	<!-- /.page-header -->
	<!-- PAGE CONTENT BEGINS -->
	<div class="row">
		<div class="col-xs-12">
			<div class="row">
				<div class="tabbable">
					<ul class="nav nav-tabs" id="myTab">
						<li class="active">
							<a>
								<i class="green icon-home bigger-110"></i>
								浏览节点
							</a>
						</li>
						<li>
							<a  href="{:U('Node/add')}">
								<i class="green icon-edit bigger-110"></i>
								添加节点
							</a>
						</li>
					</ul>
					<div class="tab-content col-xs-12">
						<div  class="tab-pane in active">
						<div class="table-responsive">
						<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
						<tr>
							<th class="center">等级</th>
							<th>节点名</th>
							<th>节点描述</th>
							<th>状态</th>
							<th class="center">操作</th>
						</tr>
						</thead>

						<tbody>
						<foreach name="list" item="v">
						<tr>
							<td >&nbsp;模块</td>
							<td>{$v.name}</td>
							<td>{$v.title}</td>
							<td>
								<eq name="v.status" value="1">
									<span class='label label-sm label-success arrowed arrowed-righ'>
										启用
									</span>
									<else/>
									<span class='label label-sm label-Default arrowed arrowed-righ'>
										禁用
									</span>
								</eq>
							</td>
							<td class="col-xs-2">
								<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
									<button class="btn btn-xs btn-info edit"  data-url="{:U('Node/edit?id='.$v['id'])}">
										<i class="icon-edit bigger-120"></i>
										编辑
									</button>
									<button class="btn btn-xs btn-danger del"  data-id="{$v.id}">
										<i class="icon-trash bigger-120"></i>
										删除
									</button>
								</div>
							</td>
						</tr>
							<notempty name="v.children">
								<foreach name="v.children" item="j">
									<tr>
										<td >{:str_repeat("&nbsp;",$j['level']*2)}—| 控制器</td>
										<td> {:str_repeat("&nbsp;",$j['level']*2)}—| {$j.name}</td>
										<td> {:str_repeat("&nbsp;",$j['level']*2)}—| {$j.title}</td>
										<td>
											<eq name="j.status" value="1">
									<span class='label label-sm label-success arrowed arrowed-righ'>
										启用
									</span>
												<else/>
									<span class='label label-sm label-Default arrowed arrowed-righ'>
										禁用
									</span>
											</eq>
										</td>
										<td class="col-xs-2">
											<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
												<button class="btn btn-xs btn-info edit"   data-url="{:U('Node/edit?id='.$j['id'])}">
													<i class="icon-edit bigger-120"></i>
													编辑
												</button>
												<button class="btn btn-xs btn-danger del"   data-id="{$j.id}">
													<i class="icon-trash bigger-120"></i>
													删除
												</button>
											</div>
										</td>
									</tr>
									<notempty name="j.children">
										<foreach name="j.children" item="x">
											<tr>
												<td >{:str_repeat("&nbsp;",$x['level']*3)}—| 方法</td>
												<td> {:str_repeat("&nbsp;",$x['level']*3)}—| {$x.name}</td>
												<td> {:str_repeat("&nbsp;",$x['level']*3)}—| {$x.title}</td>
												<td>
													<eq name="x.status" value="1">
									<span class='label label-sm label-success arrowed arrowed-righ'>
										启用
									</span>
														<else/>
									<span class='label label-sm label-Default arrowed arrowed-righ'>
										禁用
									</span>
													</eq>
												</td>
												<td class="col-xs-2">
													<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
														<button class="btn btn-xs btn-info edit"  data-url="{:U('Node/edit?id='.$x['id'])}">
															<i class="icon-edit bigger-120"></i>
															编辑
														</button>
														<button class="btn btn-xs btn-danger del"  data-id="{$x.id}">
															<i class="icon-trash bigger-120"></i>
															删除
														</button>
													</div>
												</td>
											</tr>

										</foreach>
									</notempty >
								</foreach>
							</notempty >
						</foreach>
						</tbody>
						</table>
						</div><!-- /.table-responsive -->
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- PAGE CONTENT END -->
</div>
</div>
</div>
<script>
	seajs.use(['$','bootbox'],function($){
		$("button.edit,button#addChild").click(function(){
			window.location.href = $(this).attr("data-url");
		});
		$("button.del").click(function(){
			if(confirm("确定要删除该节点吗？")){
				$id = $(this).attr("data-id");
				$.ajax({
					url:"{:U('Node/delete')}",
					data:{id:$id},
					type:"get",
					success:function(data){
						if(data.status > 0 ){
							bootbox.confirm(data.info,function(result){
								if(result){
									window.location.reload();
									return false;
								}
							});
						}else{
							bootbox.alert({
								message:data.info,
								title: "提示信息"
							});
							return false;
						}
					}
				})
			}
		});

	})
</script>
<include file="Public/footer"/>

